package com.bwie.controller;
import com.bwie.pojo.Brand;
import com.bwie.service.BrandService;
import com.bwie.service.impl.BrandServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* 品牌表(tb_brand)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/shop/brand")
public class BrandController {
/**
* 服务对象
*/
    @Autowired
    private BrandService brandService;

    @ApiOperation("分页获取品牌列表")
    @PostMapping("/getBrandList")
    public R getBrandList(@RequestBody PageInfoVo pageInfoVo){
        return brandService.getBrandList(pageInfoVo);
    }

    @ApiOperation("添加品牌")
    @PostMapping("/addBrand")
    public R addBrand(@RequestBody @Validated Brand brand){
        return brandService.addBrand(brand);
    }

    @ApiOperation("修改品牌显示状态")
    @PostMapping("/changeBrandStatus")
    public R changeBrandStatus(@RequestBody Brand brand) {
        return brandService.changeBrandStatus(brand);
    }

    @ApiOperation("单删除")
    @PostMapping("/deleteBrand/{brandId}")
    public R deleteBrand(@PathVariable("brandId")Integer brandId){
        return brandService.deleteBrand(brandId);
    }

    @ApiOperation("批量删除")
    @PostMapping("/deletebatchBrand")
    public R deletebatchBrand(@RequestBody List<Brand> brandList){
        return brandService.deletebatchBrand(brandList);
    }

}
